//package com.nuo.modules.video.interceptor;
//
//import cn.hutool.system.UserInfo;
//import com.alibaba.fastjson.JSONObject;
//import com.nuo.common.exception.GlobalException;
//import com.nuo.common.threadlocal.ThreadLocalDemo;
//import com.nuo.common.utils.HttpContextUtils;
//import com.nuo.common.utils.InfoUtils;
//import com.nuo.common.utils.SpringContextUtils;
//import com.nuo.modules.teacher.entity.TeacherEntity;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//import org.springframework.web.servlet.HandlerInterceptor;
//import org.springframework.web.servlet.ModelAndView;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.util.Map;
//
///**
// * @description: TODO 认证拦截
// * @author nuo
// * @date 2022/11/21 12:40
// * @version 1.0
// */
//@Component
//@Slf4j
//public class SignInterceptor implements HandlerInterceptor {
//
//    @Autowired
//    private ThreadLocalDemo threadLocalDemo;
//
//    @Autowired
//    InfoUtils<TeacherEntity> infoUtils;
//
//    @Override
//    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//        log.warn("sessionId: " + request.getSession().getId());
//        Object sign = request.getSession().getAttribute("sign");
//        String bodyString = SpringContextUtils.getBodyString(request);
//        JSONObject jsonObject = JSONObject.parseObject(bodyString);
//        // 验证 token
//        // infoUtils.getIdByToken((String) jsonObject.get("token"), 2);
//        // 判断认证
//
//
//
//
//        if (sign == null) {
//            throw new GlobalException("请先签到认证...", 403);
//        }
//        threadLocalDemo.set(jsonObject);
//        return true;
//    }
//
//    @Override
//    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
//        HandlerInterceptor.super.postHandle(request, response, handler, modelAndView);
//    }
//
//    @Override
//    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
//        threadLocalDemo.remove();
//        HandlerInterceptor.super.afterCompletion(request, response, handler, ex);
//    }
//}
